#!/usr/bin/python3

from QQWry import QQWry
import ipdb

def main(args):
  if len(args) == 1:
    ip = args[0]
    if '.' in ip:
      Q = QQWry()
      print(''.join(Q[ip][2:]))
    else:
      D = ipdb.IPDB(ipdb.DEFAULT_FILE_LOCATION)
      print(' '.join(D.lookup(ip).info).replace('\t', ' '))
    return

  Q = QQWry()
  D = ipdb.IPDB(ipdb.DEFAULT_FILE_LOCATION)
  for ip in args:
    if '.' in ip:
      print(Q[ip])
    else:
      print(D.lookup(ip))

if __name__ == '__main__':
  import sys
  main(sys.argv[1:])
